package cn.wildfire.chat.app.extendsion.adapters;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sourcemuch.im.caiba.R;import com.sourcemuch.im.caiba.R2;

import cn.wildfire.chat.app.extendsion.classes.RequestCommonGroupEntity;
import cn.wildfire.chat.kit.conversation.ConversationActivity;
import cn.wildfirechat.model.Conversation;

/**
 * @Author Administrator
 * @Date 2019/9/25
 */
public class CommonGroupAdapter extends BaseQuickAdapter<RequestCommonGroupEntity.ResultBean, BaseViewHolder> {
    Activity activity;

    public CommonGroupAdapter(Activity activity, int layoutResId) {
        super(layoutResId);
        this.activity = activity;

    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, RequestCommonGroupEntity.ResultBean item) {
        ImageView gportrait = helper.getView(R.id.cv_common_group);
        Glide.with(activity).load(item.getGportrait()).into(gportrait);
        helper.setText(R.id.tv_group_name, item.getGname());
        helper.setText(R.id.tv_friend_nick, activity.getString(R.string.friend_in_group_nick) + "\"" + item.getFriendGroupAlias() + "\"");

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(activity, ConversationActivity.class);
                Conversation conversation = new Conversation(Conversation.ConversationType.Group, item.getGid(), 0);
                intent.putExtra("conversation", conversation);
                activity.startActivity(intent);
            }
        });
    }
}
